#ifndef STX_ALGORITHM_FILL_HPP
#define STX_ALGORITHM_FILL_HPP

#include <stx/algorithm/common.hpp>
#include <stx/algorithm/fill_n.hpp>

namespace stx {

template <class ForwardIterator, class T>
inline void
fill_impl(ForwardIterator first, ForwardIterator last, const T& value, std::forward_iterator_tag)
{
    for (; first != last; ++first) {
        *first = value;
    }
}

template <class RandomAccessIterator, class T>
inline void
fill_impl(RandomAccessIterator first, RandomAccessIterator last, const T& value, std::random_access_iterator_tag)
{
    stx::fill_n(first, last - first, value);
}

template <class ForwardIterator, class T>
inline void
fill(ForwardIterator first, ForwardIterator last, const T& value)
{
    stx::fill_impl(first, last, value, typename std::iterator_traits<ForwardIterator>::iterator_category());
}

} // namespace stx

#endif // STX_ALGORITHM_FILL_HPP
